<template>
	<view class="gradens-xcjh-report">
		<view class="gradens-yhrw-view-card">
			<view class="yhrw-view-list-item">
				<view class="title">{{patrolPlanInfo.planName}}</view>
			</view>
			<view class="yhrw-view-list-item">
				<view class="yhrw-view-list-name">巡查开始时间:</view>
				<text class="yhrw-view-list-text">{{patrolPlanInfo.patrolStartTime | date("yyyy年mm月dd日")}}</text>
			</view>
			<view class="yhrw-view-list-item">
				<view class="yhrw-view-list-name">巡查结束时间:</view>
				<text class="yhrw-view-list-text">{{patrolPlanInfo.patrolEndTime | date("yyyy年mm月dd日")}}</text>
			</view>
			<view class="yhrw-view-list-item">
				<view class="yhrw-view-list-name" style="width: 125rpx;">巡查类型:</view>
				<text class="yhrw-view-list-text">{{patrolPlanInfo.patrolType}}</text>
				<view class="yhrw-view-list-name" style="width: 125rpx;margin-left: 100rpx;">次数要求:</view>
				<text class="yhrw-view-list-text">{{patrolPlanInfo.numberRequire}}</text>
			</view>
			<view class="" style="border-bottom: 1px solid #c5c5c5;margin-top: 20rpx;"></view>
			<view class="yhrw-view-list-item">
				<view class="yhrw-view-list-name">巡查日期:</view>
				<text class="yhrw-view-list-text">{{patrolEnterInfo.patrolTime | date("yyyy年mm月dd日")}}</text>
			</view>
			<view class="yhrw-view-list-item">
				<view class="yhrw-view-list-name">是否异常:</view>
				<text class="yhrw-view-list-text">{{patrolEnterInfo.isAbnormal === '0'?'正常':'异常' }}</text>
			</view>
			<view class="yhrw-view-list-item">
				<view class="yhrw-view-list-name">巡查记录:</view>
				<text class="yhrw-view-list-text">{{patrolEnterInfo.patrolRecord}}</text>
			</view>
			<view class="yhrw-view-list-item">
				<view class="yhrw-view-list-name">上报人:</view>
				<text class="yhrw-view-list-text">{{patrolEnterInfo.userName}}</text>
			</view>
			<view class="yhrw-view-list-item">
				<view class="yhrw-view-list-name">上传图片:</view>
				<view v-for="(item,index) in imgList" :key="item.attachId" v-if="imgList.length>0"
					style="margin-right: 20rpx;">
					<img class="img" :src="item.src" alt="" srcset="" @click="previewImg(index)">
				</view>
				<view v-if="imgList.length === 0">暂无图片</view>
			</view>
			<view class="yhrw-view-list-item">
				<view class="yhrw-view-list-name">巡查距离:</view>
				<text class="yhrw-view-list-text">暂无数据</text>
			</view>
			<view class="yhrw-view-list-item">
				<view class="yhrw-view-list-name">巡查速度:</view>
				<text class="yhrw-view-list-text">暂无数据</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getPatrolEnter,
	} from "@/api/comp/patrolEnter";
	import {
		getPatrolPlan,
	} from "@/api/comp/patrolPlan";
	import {
		getAttachList
	} from "@/api/dums/am/attach";
	import {
		baseUrl
	} from "@/config";
	export default {
		data() {
			return {
				date: new Date(),
				patrolPlanInfo: {},
				patrolEnterInfo: {},
				imgList: [],
			}
		},
		onLoad(options) {
			this.getInfo(options)
		},
		methods: {
			getInfo(options) {
				getPatrolPlan(options.planId).then(res => {
					if (res.data) {
						this.patrolPlanInfo = res.data
					}
				})
				getPatrolEnter(options.id).then(res => {
					if (res.data) {
						this.patrolEnterInfo = res.data
					}
				})
				getAttachList({
					mianId: options.id,
					bussType: "td_comp_patrol_enter",
				}).then(res => {
					this.imgList = res.rows
					this.imgList.map(item => {
						item.src = baseUrl + '/file/' + item.fileUrl
					})
				})
			},
			previewImg(index) {
				// 过滤
				let imgUrl = this.imgList.map(item => item.src)
				uni.previewImage({
					current: index, //点击的索引值
					urls: imgUrl,
				})
			},
			backClick() {
				uni.navigateBack()
			},
		}
	}
</script>

<style scoped>
	.yhrw-view-list-item {
		display: flex;
		margin-top: 20rpx;
		margin-left: 20rpx;
	}

	.img {
		width: 150rpx;
		height: 150rpx;
		object-fit: cover;
	}
	.title{
		font-weight: bold;
	}

	.yhrw-view-list-name {
		margin-right: 10rpx;
		color:#9DA0AA;
		font-size: 26rpx;
	}
	.yhrw-view-list-text {
		flex: 1;
		color:#353B50;
		font-size: 26rpx;
	}
</style>